// 借鉴 vue 源码中的相关代码
const hasOwnProperty = Object.prototype.hasOwnProperty
const objectToString = Object.prototype.toString
const toTypeString = (v: any) => objectToString.call(v)
const toRawType = (v: any) => {
  // extract "RawType" from strings like "[object RawType]"
  return toTypeString(v).slice(8, -1)
}

export const NOOP = (...args: any[]) => {}
export const hasOwn = (v: Record<string, unknown>, k: PropertyKey) => hasOwnProperty.call(v, k)
export const isArray = Array.isArray
export const isObject = (v: any) => v !== null && typeof v === 'object'
export const isPlainObject = (v: any) => toTypeString(v) === '[object Object]'
export const isString = (v: any) => typeof v === 'string'
export const isSymbol = (v: any) => typeof v === 'symbol'
export const isDate = (v: any) => v instanceof Date
export const isFunction = (v: any) => typeof v === 'function'
export const isMap = (v: any) => toTypeString(v) === '[object Map]'
export const isSet = (v: any) => toTypeString(v) === '[object Set]'
export const isPromise = (v: any) => isObject(v) && isFunction(v.then) && isFunction(v.catch)

export const isUndefined = (v: any): boolean => v === undefined || v === null
export const isDefined = (v: any): boolean => v !== undefined && v !== null
